﻿
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OptikinetiqControls
{
    public class DrawCircle
    {
        /// <summary>
        /// 圆心坐标
        /// </summary>
        public PointF center;
        /// <summary>
        /// 半径
        /// </summary>
        public float radius;

        private Color _selectColor;
        public Color selectColor
        {
            get { return _selectColor; }
        }

        private Color _penColor;
        public Color penColor
        {
            get { return _penColor; }
            set
            {
                _penColor = value;

                int r = 255 - value.R;
                int g = 255 - value.G;
                int b = 255 - value.B;
                _selectColor = Color.FromArgb(r, g, b);
            }
        }

        private float _penSize;

        public float penSize
        {
            get { return _penSize; }
            set { _penSize = value; }
        }

        public bool isSelect;

        /// <summary>
        /// 获取圆直径
        /// </summary>
        /// <returns></returns>
        public float GetDiameter() {
            return radius * 2;
        }

        /// <summary>
        /// 获取圆的最小外接矩形，用于绘制内切圆
        /// </summary>
        /// <returns></returns>
        public RectangleF GetBindRect() {
            //计算外接矩形左上角坐标
            PointF LT = new PointF(center.X - radius, center.Y - radius);
            SizeF size = new SizeF(radius * 2, radius * 2);
            return new RectangleF(LT, size);
        }

        /// <summary>
        /// 获取外接矩形的左上角像素坐标
        /// </summary>
        /// <returns></returns>
        public PointF GetRectTL() {
            //计算外接矩形左上角坐标
            PointF TL = new PointF(center.X - radius, center.Y - radius);

            return TL;
        }

        /// <summary>
        /// 获取外接矩形的右下角坐标
        /// </summary>
        /// <returns></returns>
        public PointF GetRectBR() {
            //计算外接矩形左上角坐标
            PointF BR = new PointF(center.X + radius, center.Y + radius);

            return BR;
        }

        /// <summary>
        /// 获取缩放点
        /// </summary>
        /// <returns></returns>
        public PointF GetScalePoint() {
            PointF dragPoint = new PointF(center.X + radius, center.Y);
            return dragPoint;
        }


        public double GetArea() {
            double s = Math.PI * Math.Pow(radius, 2);
            return s;
        }

        public double GetPerimeter() {
            double p = Math.PI * radius * 2;
            return p;
        }

        public float GetDiamiter() {
            return radius * 2;
        }

        public float GetCenterSize() {
            return GetDiamiter() / 10;
        }
    }
}
